package cn.bass.marketing.service.activity.impl;

import cn.bass.marketing.common.vo.req.MarketingActivityReqVO;
import cn.bass.marketing.entity.MarketingActivityDO;
import cn.bass.marketing.mapper.MarketingActivityMapper;
import cn.bass.marketing.service.activity.MarketingActivityService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Objects;

@Slf4j
@Service
public class MarketingActivityServiceImpl extends ServiceImpl<MarketingActivityMapper, MarketingActivityDO> implements MarketingActivityService {

    @Override
    public List<MarketingActivityDO> getActivityList(MarketingActivityReqVO marketingActivityReqVO) {
        log.info("marketingActivityReqVO: {}", marketingActivityReqVO);
        LambdaQueryWrapper<MarketingActivityDO> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(Objects.nonNull(marketingActivityReqVO.getCId()), MarketingActivityDO::getCId, marketingActivityReqVO.getCId());
        queryWrapper.eq(Objects.nonNull(marketingActivityReqVO.getCActivityId()), MarketingActivityDO::getCActivityId, marketingActivityReqVO.getCActivityId());
        queryWrapper.eq(Objects.nonNull(marketingActivityReqVO.getCStartDate()), MarketingActivityDO::getCStartDate, marketingActivityReqVO.getCStartDate());
        queryWrapper.eq(Objects.nonNull(marketingActivityReqVO.getCEndDate()), MarketingActivityDO::getCEndDate, marketingActivityReqVO.getCEndDate());
        queryWrapper.like(Objects.nonNull(marketingActivityReqVO.getCName()), MarketingActivityDO::getCName, marketingActivityReqVO.getCName());
        return this.baseMapper.selectList(queryWrapper);
    }
}
